package org.sachiew;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;

/**
 * Data Object Map
 */
public class MyDOM {
    private ArrayList<MyLink> rawData = new ArrayList<MyLink>();

    public void reader(String path) {
        File file = new File(path);
        BufferedReader bf;
        try {
            bf = new BufferedReader(new FileReader(file));
            String line = bf.readLine();
            while (line != null) {
                String[] items = line.split(",");
                MyLink mylink = new MyLink();
                MyLink reverseMyLink = new MyLink();

                mylink.setMainPoint(items[1]);
                mylink.setAttachPoint(items[0]);
                rawData.add(mylink);

                reverseMyLink.setMainPoint(items[0]);
                reverseMyLink.setAttachPoint(items[1]);
                rawData.add(reverseMyLink);

                line = bf.readLine();
            }
            bf.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public ArrayList<MyLink> getRawData() {
        return rawData;
    }
}